<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>幸运大抽奖活动</title>
  <!-- 引入Tailwind CSS -->
  <script src="https://cdn.tailwindcss.com"></script>
  <!-- 引入Font Awesome -->
  <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
  
  <!-- 配置Tailwind自定义颜色和字体 -->
  <script>
    tailwind.config = {
      theme: {
        extend: {
          colors: {
            primary: '#FF6B35',
            secondary: '#FFD166',
            accent: '#06D6A0',
            dark: '#118AB2',
            light: '#F7F9FC'
          },
          fontFamily: {
            sans: ['Inter', 'system-ui', 'sans-serif'],
          },
        },
      }
    }
  </script>
  
  <!-- 自定义工具类 -->
  <style type="text/tailwindcss">
    @layer utilities {
      .content-auto {
        content-visibility: auto;
      }
      .text-shadow {
        text-shadow: 0 2px 4px rgba(0,0,0,0.2);
      }
      .text-shadow-lg {
        text-shadow: 0 4px 8px rgba(0,0,0,0.3);
      }
      .rotate-spin {
        animation: spin 8s cubic-bezier(0.17, 0.67, 0.13, 0.99) forwards;
      }
      .prize-item-hover {
        transition: all 0.3s ease;
      }
      .prize-item-hover:hover {
        transform: translateY(-5px) scale(1.02);
        box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
      }
    }
  </style>
  
  <style>
    /* 抽奖转盘样式 */
    .lottery-wheel {
      position: relative;
      width: 100%;
      max-width: 500px;
      aspect-ratio: 1/1;
      border-radius: 50%;
      overflow: hidden;
      transition: transform 0.3s ease;
    }
    
    .lottery-section {
      position: absolute;
      width: 50%;
      height: 50%;
      transform-origin: bottom right;
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: hidden;
    }
    
    .lottery-section-content {
      position: absolute;
      width: 100px;
      text-align: center;
      transform-origin: center;
      font-weight: bold;
      padding: 10px;
      transform: rotate(45deg) translate(30px, 0);
    }
    
    .lottery-pointer {
      position: absolute;
      top: -15px;
      left: 50%;
      transform: translateX(-50%);
      width: 0;
      height: 0;
      border-left: 20px solid transparent;
      border-right: 20px solid transparent;
      border-top: 30px solid #FF3366;
      z-index: 10;
      filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
    }
    
    .lottery-center {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      width: 25%;
      height: 25%;
      border-radius: 50%;
      background-color: white;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      z-index: 5;
      box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
      transition: all 0.2s ease;
    }
    
    .lottery-center:hover {
      transform: translate(-50%, -50%) scale(1.05);
      box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    }
    
    .lottery-center:active {
      transform: translate(-50%, -50%) scale(0.98);
    }
    
    /* 动画效果 */
    @keyframes spin {
      0% { transform: rotate(0deg); }
      100% { transform: rotate(calc(360deg * 8 + var(--rotation, 0deg))); }
    }
    
    @keyframes pulse {
      0%, 100% { transform: scale(1); }
      50% { transform: scale(1.05); }
    }
    
    @keyframes bounce-in {
      0% { transform: scale(0.8); opacity: 0; }
      70% { transform: scale(1.1); }
      100% { transform: scale(1); opacity: 1; }
    }
    
    .animate-bounce-in {
      animation: bounce-in 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    }
    
    .animate-pulse-slow {
      animation: pulse 2s infinite;
    }
    
    /* 中奖弹窗动画 */
    .prize-popup {
      opacity: 0;
      visibility: hidden;
      transform: scale(0.9);
      transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }
    
    .prize-popup.active {
      opacity: 1;
      visibility: visible;
      transform: scale(1);
    }
    
    /* 自定义滚动条 */
    ::-webkit-scrollbar {
      width: 6px;
      height: 6px;
    }
    
    ::-webkit-scrollbar-track {
      background: #f1f1f1;
      border-radius: 3px;
    }
    
    ::-webkit-scrollbar-thumb {
      background: #c1c1c1;
      border-radius: 3px;
    }
    
    ::-webkit-scrollbar-thumb:hover {
      background: #a1a1a1;
    }
  </style>
</head>
<body class="bg-gradient-to-br from-light to-blue-50 min-h-screen font-sans text-gray-800">
  <!-- 页面顶部装饰 -->
  <div class="absolute top-0 left-0 w-full overflow-hidden h-32 pointer-events-none">
    <div class="absolute -top-10 -left-10 w-40 h-40 bg-primary/10 rounded-full blur-3xl"></div>
    <div class="absolute -top-20 right-20 w-60 h-60 bg-secondary/10 rounded-full blur-3xl"></div>
  </div>

  <!-- 页面头部 -->
  <header class="relative py-8 px-4 sm:px-6 lg:px-8">
    <div class="container mx-auto text-center">
      <div class="inline-block relative mb-3">
        <span class="inline-block bg-primary text-white text-xs px-3 py-1 rounded-full font-medium">
          限时活动
        </span>
        <div class="absolute -top-1 -right-1 w-4 h-4 bg-red-500 rounded-full animate-ping"></div>
      </div>
      <h1 class="text-[clamp(1.8rem,5vw,3rem)] font-bold text-shadow-lg bg-clip-text text-transparent bg-gradient-to-r from-primary to-dark mb-3">
        幸运大抽奖
      </h1>
      <p class="text-gray-600 max-w-2xl mx-auto mb-6">
        参与抽奖赢取丰厚奖品，每个用户每天有3次抽奖机会，好礼等你来拿！
      </p>
      <div class="flex justify-center items-center gap-4 text-sm text-gray-500">
        <div class="flex items-center">
          <i class="fa fa-clock-o text-primary mr-1"></i>
          <span>活动时间: 2023-10-01 至 2023-10-15</span>
        </div>
        <div class="hidden sm:block w-px h-5 bg-gray-300"></div>
        <div class="flex items-center">
          <i class="fa fa-user text-primary mr-1"></i>
          <span>剩余次数: <span id="remaining-times" class="font-bold text-primary">3</span>/3</span>
        </div>
      </div>
    </div>
  </header>

  <!-- 主内容区 -->
  <main class="container mx-auto px-4 sm:px-6 lg:px-8 py-6 flex flex-col lg:flex-row gap-8">
    <!-- 左侧：抽奖区域 -->
    <div class="w-full lg:w-1/2 flex flex-col items-center">
      <div class="relative w-full max-w-md mb-8">
        <!-- 转盘背景装饰 -->
        <div class="absolute -inset-4 bg-gradient-to-r from-primary to-dark rounded-full blur-xl opacity-20 animate-pulse-slow"></div>
        
        <!-- 抽奖转盘 -->
        <div id="lottery-wheel" class="lottery-wheel border-8 border-white shadow-2xl relative">
          <!-- 转盘分区将通过JS动态生成 -->
        </div>
        
        <!-- 转盘指针 -->
        <div class="lottery-pointer"></div>
        
        <!-- 转盘中心按钮 -->
        <div id="lottery-btn" class="lottery-center">
          <div class="text-center">
            <div class="text-primary font-bold text-lg">开始抽奖</div>
            <div class="text-xs text-gray-500">点击转动</div>
          </div>
        </div>
      </div>
      
      <!-- 抽奖规则 -->
      <div class="w-full bg-white rounded-xl shadow-lg p-5 mb-6">
        <h3 class="font-bold text-lg mb-3 flex items-center">
          <i class="fa fa-info-circle text-primary mr-2"></i>抽奖规则
        </h3>
        <ul class="text-sm text-gray-600 space-y-2">
          <li class="flex items-start">
            <i class="fa fa-check-circle text-accent mt-1 mr-2"></i>
            <span>每个用户每天有3次免费抽奖机会</span>
          </li>
          <li class="flex items-start">
            <i class="fa fa-check-circle text-accent mt-1 mr-2"></i>
            <span>分享活动可额外获得1次抽奖机会</span>
          </li>
          <li class="flex items-start">
            <i class="fa fa-check-circle text-accent mt-1 mr-2"></i>
            <span>抽中奖品后请及时填写收货信息</span>
          </li>
          <li class="flex items-start">
            <i class="fa fa-check-circle text-accent mt-1 mr-2"></i>
            <span>活动最终解释权归主办方所有</span>
          </li>
        </ul>
        <button id="share-btn" class="mt-4 w-full py-2 bg-primary/10 hover:bg-primary/20 text-primary rounded-lg transition-colors text-sm font-medium flex items-center justify-center">
          <i class="fa fa-share-alt mr-1"></i> 分享活动获取更多抽奖机会
        </button>
      </div>
    </div>
    
    <!-- 右侧：奖品和记录 -->
    <div class="w-full lg:w-1/2 flex flex-col gap-6">
      <!-- 奖品展示 -->
      <div class="bg-white rounded-xl shadow-lg p-5">
        <h3 class="font-bold text-lg mb-4 flex items-center">
          <i class="fa fa-gift text-secondary mr-2"></i>奖品设置
        </h3>
        <div class="grid grid-cols-2 sm:grid-cols-3 gap-3">
          <!-- 奖品项 -->
          <div class="bg-light rounded-lg p-3 text-center prize-item-hover">
            <div class="w-16 h-16 mx-auto mb-2 bg-primary/10 rounded-full flex items-center justify-center">
              <i class="fa fa-mobile text-2xl text-primary"></i>
            </div>
            <div class="text-sm font-medium">智能手机</div>
            <div class="text-xs text-gray-500">1份</div>
          </div>
          
          <div class="bg-light rounded-lg p-3 text-center prize-item-hover">
            <div class="w-16 h-16 mx-auto mb-2 bg-dark/10 rounded-full flex items-center justify-center">
              <i class="fa fa-laptop text-2xl text-dark"></i>
            </div>
            <div class="text-sm font-medium">笔记本电脑</div>
            <div class="text-xs text-gray-500">1份</div>
          </div>
          
          <div class="bg-light rounded-lg p-3 text-center prize-item-hover">
            <div class="w-16 h-16 mx-auto mb-2 bg-accent/10 rounded-full flex items-center justify-center">
              <i class="fa fa-headphones text-2xl text-accent"></i>
            </div>
            <div class="text-sm font-medium">蓝牙耳机</div>
            <div class="text-xs text-gray-500">5份</div>
          </div>
          
          <div class="bg-light rounded-lg p-3 text-center prize-item-hover">
            <div class="w-16 h-16 mx-auto mb-2 bg-secondary/10 rounded-full flex items-center justify-center">
              <i class="fa fa-clock-o text-2xl text-secondary"></i>
            </div>
            <div class="text-sm font-medium">智能手表</div>
            <div class="text-xs text-gray-500">10份</div>
          </div>
          
          <div class="bg-light rounded-lg p-3 text-center prize-item-hover">
            <div class="w-16 h-16 mx-auto mb-2 bg-primary/10 rounded-full flex items-center justify-center">
              <i class="fa fa-ticket text-2xl text-primary"></i>
            </div>
            <div class="text-sm font-medium">10元代金券</div>
            <div class="text-xs text-gray-500">50份</div>
          </div>
          
          <div class="bg-light rounded-lg p-3 text-center prize-item-hover">
            <div class="w-16 h-16 mx-auto mb-2 bg-gray-200 rounded-full flex items-center justify-center">
              <i class="fa fa-smile-o text-2xl text-gray-500"></i>
            </div>
            <div class="text-sm font-medium">谢谢参与</div>
            <div class="text-xs text-gray-500">-</div>
          </div>
        </div>
      </div>
      
      <!-- 中奖记录 -->
      <div class="bg-white rounded-xl shadow-lg p-5 flex-grow">
        <h3 class="font-bold text-lg mb-4 flex items-center justify-between">
          <div class="flex items-center">
            <i class="fa fa-history text-primary mr-2"></i>中奖记录
          </div>
          <span class="text-xs bg-primary/10 text-primary px-2 py-1 rounded-full">实时更新</span>
        </h3>
        <div id="winning-records" class="space-y-3 max-h-64 overflow-y-auto pr-1">
          <!-- 中奖记录将通过JS动态生成 -->
        </div>
        <div id="no-records" class="text-center py-8 text-gray-400">
          <i class="fa fa-inbox text-3xl mb-2"></i>
          <p>暂无中奖记录</p>
        </div>
      </div>
    </div>
  </main>

  <!-- 中奖弹窗 -->
  <div id="prize-popup" class="prize-popup fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50 p-4">
    <div class="bg-white rounded-2xl max-w-md w-full overflow-hidden shadow-2xl">
      <div class="relative bg-gradient-to-r from-primary to-dark p-6 text-white text-center">
        <button id="close-popup" class="absolute top-4 right-4 text-white/80 hover:text-white transition-colors">
          <i class="fa fa-times text-xl"></i>
        </button>
        <div class="inline-block w-16 h-16 rounded-full bg-white/20 flex items-center justify-center mb-3 animate-pulse-slow">
          <i class="fa fa-trophy text-2xl"></i>
        </div>
        <h3 class="text-xl font-bold">恭喜中奖！</h3>
        <p class="opacity-90">您获得了以下奖品</p>
      </div>
      <div class="p-6 text-center">
        <div id="prize-name" class="text-2xl font-bold text-gray-800 mb-4">智能手机</div>
        <div class="w-24 h-24 mx-auto mb-6 bg-primary/10 rounded-full flex items-center justify-center">
          <i id="prize-icon" class="fa fa-mobile text-4xl text-primary"></i>
        </div>
        <p class="text-gray-500 text-sm mb-6">请填写收货信息，我们将尽快为您发货</p>
        <button id="claim-prize" class="w-full py-3 bg-primary hover:bg-primary/90 text-white rounded-lg transition-colors font-medium">
          领取奖品
        </button>
      </div>
    </div>
  </div>

  <!-- 页脚 -->
  <footer class="bg-white mt-12 py-6 border-t">
    <div class="container mx-auto px-4 text-center text-gray-500 text-sm">
      <p>© 2023 幸运大抽奖活动 版权所有</p>
      <p class="mt-1">活动最终解释权归主办方所有</p>
    </div>
  </footer>

  <script>
    // DOM元素
    const lotteryWheel = document.getElementById('lottery-wheel');
    const lotteryBtn = document.getElementById('lottery-btn');
    const remainingTimesEl = document.getElementById('remaining-times');
    const prizePopup = document.getElementById('prize-popup');
    const closePopupBtn = document.getElementById('close-popup');
    const claimPrizeBtn = document.getElementById('claim-prize');
    const prizeNameEl = document.getElementById('prize-name');
    const prizeIconEl = document.getElementById('prize-icon');
    const winningRecordsEl = document.getElementById('winning-records');
    const noRecordsEl = document.getElementById('no-records');
    const shareBtn = document.getElementById('share-btn');
    
    // 数据
    let remainingTimes = 3;
    const prizes = [
      { name: '智能手机', icon: 'fa-mobile', color: '#FF6B35', probability: 1 },
      { name: '笔记本电脑', icon: 'fa-laptop', color: '#118AB2', probability: 1 },
      { name: '蓝牙耳机', icon: 'fa-headphones', color: '#06D6A0', probability: 5 },
      { name: '智能手表', icon: 'fa-clock-o', color: '#FFD166', probability: 10 },
      { name: '10元代金券', icon: 'fa-ticket', color: '#FF6B35', probability: 50 },
      { name: '谢谢参与', icon: 'fa-smile-o', color: '#E5E7EB', probability: 33 }
    ];
    
    // 中奖记录
    const winningRecords = [
      { user: '用户138****5678', prize: '10元代金券', time: '10:23' },
      { user: '用户139****8901', prize: '蓝牙耳机', time: '10:15' },
      { user: '用户135****2345', prize: '谢谢参与', time: '10:08' },
      { user: '用户136****6789', prize: '10元代金券', time: '09:56' },
      { user: '用户137****0123', prize: '智能手表', time: '09:42' }
    ];
    
    // 初始化转盘
    function initLotteryWheel() {
      const sectionCount = prizes.length;
      const angle = 360 / sectionCount;
      
      // 清空转盘
      lotteryWheel.innerHTML = '';
      
      // 创建转盘分区
      prizes.forEach((prize, index) => {
        const section = document.createElement('div');
        section.className = 'lottery-section';
        section.style.transform = `rotate(${index * angle}deg)`;
        section.style.backgroundColor = index % 2 === 0 ? `${prize.color}33` : `${prize.color}22`;
        
        const content = document.createElement('div');
        content.className = 'lottery-section-content';
        content.style.color = prize.color;
        content.textContent = prize.name;
        
        section.appendChild(content);
        lotteryWheel.appendChild(section);
      });
    }
    
    // 初始化中奖记录
    function initWinningRecords() {
      if (winningRecords.length === 0) {
        noRecordsEl.classList.remove('hidden');
        return;
      }
      
      noRecordsEl.classList.add('hidden');
      winningRecordsEl.innerHTML = '';
      
      winningRecords.forEach(record => {
        const recordEl = document.createElement('div');
        recordEl.className = 'flex justify-between items-center p-2 border-b border-gray-100 last:border-0';
        
        const isPrize = record.prize !== '谢谢参与';
        
        recordEl.innerHTML = `
          <div class="flex items-center">
            <div class="w-8 h-8 rounded-full bg-gray-100 flex items-center justify-center mr-2">
              <i class="fa fa-user text-gray-400 text-xs"></i>
            </div>
            <div>
              <div class="text-sm">${record.user}</div>
              <div class="text-xs text-gray-500">${record.time}</div>
            </div>
          </div>
          <div class="text-sm font-medium ${isPrize ? 'text-primary' : 'text-gray-400'}">
            ${isPrize ? '<i class="fa fa-gift mr-1"></i>' : ''}${record.prize}
          </div>
        `;
        
        winningRecordsEl.appendChild(recordEl);
      });
    }
    
    // 开始抽奖
    function startLottery() {
      // 检查是否还有抽奖次数
      if (remainingTimes <= 0) {
        alert('您的抽奖次数已用完，请明天再来或分享活动获取更多次数！');
        return;
      }
      
      // 禁用按钮
      lotteryBtn.disabled = true;
      lotteryBtn.style.cursor = 'not-allowed';
      
      // 减少抽奖次数
      remainingTimes--;
      remainingTimesEl.textContent = remainingTimes;
      
      // 随机选择奖品（根据概率）
      let random = Math.random() * 100;
      let selectedPrize = null;
      let cumulativeProbability = 0;
      
      for (const prize of prizes) {
        cumulativeProbability += prize.probability;
        if (random <= cumulativeProbability) {
          selectedPrize = prize;
          break;
        }
      }
      
      // 计算旋转角度（每个奖品占60度）
      const prizeIndex = prizes.indexOf(selectedPrize);
      const rotation = 360 - (prizeIndex * 60) + 30; // 30度是为了让指针指向区域中心
      
      // 设置旋转角度变量
      lotteryWheel.style.setProperty('--rotation', `${rotation}deg`);
      
      // 添加旋转动画
      lotteryWheel.classList.add('rotate-spin');
      
      // 动画结束后显示结果
      setTimeout(() => {
        // 重置转盘
        lotteryWheel.classList.remove('rotate-spin');
        
        // 启用按钮
        lotteryBtn.disabled = false;
        lotteryBtn.style.cursor = 'pointer';
        
        // 更新中奖记录
        addWinningRecord(selectedPrize);
        
        // 显示中奖弹窗（谢谢参与不弹窗）
        if (selectedPrize.name !== '谢谢参与') {
          showPrizePopup(selectedPrize);
        } else {
          alert('很遗憾，这次没有中奖，再接再厉哦！');
        }
      }, 8000); // 与动画时间一致
    }
    
    // 显示中奖弹窗
    function showPrizePopup(prize) {
      prizeNameEl.textContent = prize.name;
      prizeIconEl.className = `fa ${prize.icon} text-4xl`;
      prizeIconEl.style.color = prize.color;
      prizePopup.classList.add('active');
    }
    
    // 关闭中奖弹窗
    function closePrizePopup() {
      prizePopup.classList.remove('active');
    }
    
    // 添加中奖记录
    function addWinningRecord(prize) {
      const now = new Date();
      const timeStr = `${now.getHours()}:${now.getMinutes().toString().padStart(2, '0')}`;
      
      // 模拟当前用户
      const newRecord = {
        user: '我',
        prize: prize.name,
        time: timeStr
      };
      
      // 添加到记录列表开头
      winningRecords.unshift(newRecord);
      
      // 限制记录数量
      if (winningRecords.length > 10) {
        winningRecords.pop();
      }
      
      // 更新显示
      initWinningRecords();
    }
    
    // 分享活动
    function shareActivity() {
      if (remainingTimes >= 3) {
        alert('您已经拥有最大抽奖次数了！');
        return;
      }
      
      // 模拟分享成功
      alert('分享成功！您获得了1次额外抽奖机会');
      remainingTimes++;
      remainingTimesEl.textContent = remainingTimes;
    }
    
    // 事件监听
    lotteryBtn.addEventListener('click', startLottery);
    closePopupBtn.addEventListener('click', closePrizePopup);
    claimPrizeBtn.addEventListener('click', () => {
      alert('请在"我的奖品"中填写收货信息领取奖品');
      closePrizePopup();
    });
    shareBtn.addEventListener('click', shareActivity);
    
    // 点击弹窗外部关闭
    prizePopup.addEventListener('click', (e) => {
      if (e.target === prizePopup) {
        closePrizePopup();
      }
    });
    
    // 初始化
    window.addEventListener('load', () => {
      initLotteryWheel();
      initWinningRecords();
    });
  </script>
</body>
</html>
    